<?php
class login
{
	private $user_id;
	private $grouptype;
	private $fullname;
	
	function getuser_id()
	{
		return $this->user_id;
		
	}
	function getgrouptype()
	{
		return $this->grouptype;
		
	}
	function getfullname()
	{
		return $this->fullname;	
	}
	
	private function checkgroup($group_id)
	{
		$sql="SELECT * FROM sme_group WHERE group_id='$group_id'";
		$recSql = mysql_query( $sql);
        $record=mysql_fetch_array($recSql);
		if($record[2]=='2'){
			$this->grouptype=$record[1];
		 return TRUE;
		}
		else return FALSE;
		
	}
	function checkrecord($email,$password)
	{
	$encode_em=base64_encode($email);
	$encode_pwd=sha1($password);
	$sql="SELECT user_id ,group_id,name,lastname
			FROM sme_user  
			WHERE email='$encode_em' 
			AND password='$encode_pwd'  
			AND active='1' AND deleted='0'";

	$recSql = mysql_query( $sql);
    $record=mysql_fetch_array($recSql);
		if($record[0]!=NULL)
		{
			if($this->checkgroup($record[1]))
			{
				$this->user_id=$record[0];
				$this->fullname=$record[2]." ".$record[3];
				 return TRUE;
			}
			else return FALSE;
		}
		else return FALSE;	
	}
}


?>